package com.iwhalecloud.bss.kite.cucc.listener.prod.local;

import com.iwhalecloud.bss.kite.event.prod.AddProdFuncEvent;
import com.iwhalecloud.bss.kite.manager.api.IQuerySceneInstService;
import com.iwhalecloud.bss.kite.manager.inst.KiteProdInst;
import com.iwhalecloud.bss.kite.manager.inst.KiteProdInstFunc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.core.annotation.Order;
import org.springframework.scheduling.annotation.Async;

import java.util.List;

/**
 * 附加产品勾选属性变换展示事件监听器
 */
public class LocalChangeProdAttrsFuncListener {
    @Autowired
    private IQuerySceneInstService querySceneInstService;

    /**
     * 勾选产品，联动其他附加产品属性
     *
     * @param event
     */
    @EventListener
    @Order(4)
    @Async
    public void changeProdAttrsShowDeal(AddProdFuncEvent event) {
        if (event.isOldInst()) {
            return;
        }
        String prodId = event.getFuncProdId();
        String prodInstId = event.getProdInstId();
        String sceneInstId = event.getSceneInstId();
        String custId = event.getCustId();
        String staffId = event.getStaffId();

        //获取所有产品实例
        List<KiteProdInst> kiteProdInsts=querySceneInstService.listProdInsts(sceneInstId);

        KiteProdInstFunc kiteProdInstFunc = querySceneInstService.getProdInstFunc(custId, event.getFuncProdInstId());
        KiteProdInst kiteProdInst = querySceneInstService.getProdInst(custId, event.getProdInstId());
        if (kiteProdInst == null || kiteProdInstFunc == null) {
            return;
        }

    }
}
